package com.superquan.selfstudybootmybatis.utils.superangle;

import com.superquan.selfstudybootmybatis.entity.user.User;
import com.superquan.selfstudybootmybatis.entity.vo.UserVo;
import net.sf.json.JSONObject;
import org.apache.commons.lang.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;

/**
 * @program: self-study-bootmybatis
 * @ClassName AngleTest
 * @description:
 * @author: zwq
 **/
public class AngleTest {
    public static void main(String[] args) {
        //super()的使用
        Student student = new Student("father", "son");
        student.getInfo();
        //如何跳出当前的多重循环
        ok: //定义一个标号
        for (int i = 0; i < 10; i++) {
            for (int j = 0; j < 10; j++) {
                System.out.println("i=" + i + ",j=" + j);
                if (j == 5) {
                    break ok;
                }
            }
        }
        //++1和1++的区别
        int num=1;
        int sum=10;
        sum=++sum+1;//++在前，先自加在运算。sum=10+1+1=12
        num=num+++2;//++在后，先运算在自加。sum=1+2=3
        System.out.println(sum);
        System.out.println(num);
//        copyPorperties();

        StringBuilder builder = new StringBuilder(4000);
        builder.append("SELECT CONVERT(VARCHAR(10), POI.POI_CODE) AS dealerId, POI.POI_NAME AS name, POI.ADDRESS AS address, ");
        builder.append("CUST.NICK_NAME AS contact, POI.TELEPHONE AS number, ISNULL((SELECT TOP 1 PDTL.FILE_URL FROM CRM_PIC_INFO PIC WITH(NOLOCK) ");
        builder.append("LEFT OUTER JOIN CRM_PIC_INFO_DETAIL PDTL WITH(NOLOCK) ON PDTL.P_ID = PIC.ID ");
        builder.append("WHERE PIC.BELONGS_ID = CAST(POI.POI_CODE AS VARCHAR) ");
        builder.append("AND (PIC.BELONGS_TYPE IS NULL OR PIC.BELONGS_TYPE = '')), '') AS headPic, ");
        builder.append("ISNULL(CAST(CAST(POI.LONGITUDE AS DECIMAL(18,12)) AS VARCHAR),'0.0') AS longitude, ");
        builder.append("ISNULL(CAST(CAST(POI.LATITUDE AS DECIMAL(18,12)) AS VARCHAR),'0.0') AS latitude, ");
        builder.append("ISNULL(CON.AFTER_SALE_SERVICE, 0) AS afterSaleService, ");
        builder.append("ISNULL(CON.QUALITY_SAFE, 0) AS qualitySafe, ISNULL(CON.DELIVERY_TIME, 1) AS deliveryTime, '' AS dealertips ");
        builder.append("FROM CRM_POI_INFO POI  WITH (NOLOCK) LEFT JOIN CRM_DEALER_CONTRACT CON WITH(NOLOCK) ON POI.POI_CODE = CON.ORG_ID ");
        builder.append("LEFT JOIN CRM_WS_CUSTOMER CUST WITH(NOLOCK) ON POI.POI_CODE = CUST.ORG_ID AND CUST.CUST_TITLE = '经销商' ");
        builder.append("INNER JOIN CRM_DEALER_PROD_BRAND_LINK DBL WITH(NOLOCK) ON POI.POI_CODE = DBL.ORG_ID ");
        builder.append(
                "LEFT JOIN CRM_BRAND_DEALER_SCOPE SGP WITH (NOLOCK) ON SGP.POI_CODE = POI.POI_CODE AND SGP.BRAND_CODE = ? ");
        // -- 品牌销售区域过滤
        builder.append("WHERE EXISTS(SELECT 1 FROM CRM_BRAND_CITY BC WITH(NOLOCK) INNER JOIN CRM_CITY_AREA CA WITH(NOLOCK) ");
        builder.append("ON BC.CITY_ID = CA.AREA_ID WHERE BC.BRAND_CODE=? AND EXISTS( ");
        builder.append("SELECT 1 FROM CRM_POI_INFO P WITH(NOLOCK) LEFT JOIN CRM_WS_CUSTOMER C WITH(NOLOCK) ON P.POI_CODE = C.ORG_ID WHERE 1 = 1 ");
        // -- 参数1：门店用户ID
        builder.append("AND C.CUSTOMER_ID = ? ");
        builder.append("AND P.REGION_CODE LIKE CA.SIMPLE_CITY_ID + '%' AND POI.REGION_CODE LIKE CA.SIMPLE_CITY_ID + '%')) ");
        // -- 排除设置了配送范围的经销商
        builder.append("AND SGP.POI_CODE IS NULL ");
        builder.append("AND POI.STATUS = '1' AND POI.POI_TYPE = 'dealer' AND ISNULL(POI.IS_EFFICTIVE, 1) <> 0 ");
        // -- 参数2：品牌编码
        builder.append("AND DBL.BRAND_CODE = ? ");
        // -- 参数3：排除惠配货经销商 订货全正品 下单有优惠
        builder.append("AND POI.POI_CODE <> 1580824 ");
        // -- 二分商经销商账户关联过滤
        builder.append("AND NOT EXISTS (SELECT relation.DST_POI_CODE FROM HXD_DISTRIBUTOR_DEALER_BIND_RELATION relation WITH(NOLOCK) WHERE relation.DST_POI_CODE = POI.POI_CODE AND relation.CHECK_STATUS = 1 )");
        System.out.println(builder.toString());
    }

    public static void copyPorperties(){
        User user=new User();
        UserVo userVo=new UserVo();
        user.setId(10001);
        user.setUserName("固特异销售");
        user.setPassword("1008611");
        user.setRealName("固特异1001");
        BeanUtils.copyProperties(user,userVo);
        Object s = JSONObject.fromObject(user);
        System.out.println(s);
        userVo.setRealName("固特异10010");
        System.out.println(user.getRealName()==userVo.getRealName());
        System.out.println(user.getRealName().hashCode());
        System.out.println(userVo.getRealName().hashCode());
    }
}
